﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

namespace Chemix
{
    public enum LogLevel
    {
        Verbose,
        Message,
        Warning,
        Error,
        None,
    }

    /// <summary>
    /// ChemixConfig contains the config information of the engine.
    /// </summary>
    [CreateAssetMenu(fileName = "NewChemixConfig", menuName = "Chemix/Config", order = 3)]
    public class ChemixConfig : ScriptableObject
    {
        [Header("Simulation")]

        [Tooltip("When enabled, the equations in database will be filtered out if it's impossible to happen in current scene. " +
            "Enabling this can improving performance, but if you run into trouble, you can disable this.")]
        public bool filterEquation = false;

        [Tooltip("Global rate for reactions. Increase(or decrease) this to speed up(or slow down) all reactions uniformly.")]
        public float globalReactionRate = 0.4f;

        [Tooltip("Parameter for controlling curve reaction rate. ImpactFactor = SubstanceMass / MiddleMass")]
        public float middleMass = 0.25f;

        [Tooltip("Parameter for controlling curve reaction rate. Indicates the minimal value of impact factor for each substance.")]
        [Range(0.1f, 0.9f)]
        public float minMultiplier = 0.5f;

        [Tooltip("Parameter for controlling curve reaction rate. Indicates the maximal value of impact factor for each substance.")]
        [Range(1.1f, 10f)]
        public float maxMultiplier = 2.0f;

        [Header("Gas System")]

        [Tooltip("Specifies whether to enable gas system. When enabled, gas substance will travel between containers.")]
        public bool enableGasSystem = true;

        [Tooltip("Specifies the transmit rate of gas.")]
        public float gasTransmitRate = 0.15f;

        [Tooltip("Constant to control air pressure.")]
        public float airConstant = 0.1f;

        [Header("Guidance System")]

        public TaskFlowAsset guidanceAsset;

        [Tooltip("Specifies the playback speed of guidance text animation.")]
        public int tipAnimCycle = 4;

        [Tooltip("Specifies the initial step index for guidance asset. This is used to skip the first few steps for ease of testing")]
        public int tipInitialStepIndex = 0;

        [Header("Heat System")]

        [Tooltip("Specifies the default temperature of objects.")]
        public float roomTemperature = 20f;

        [Tooltip("Specifies the temperature of flame.")]
        public float flameTemperature = 300f;

        [Tooltip("Specifies how fast heat spreads.")]
        public float heatRate = 50f;

        [Header("Miscellaneous")]

        [Tooltip("When enabled, player can use mouse to move and interact with objects.")]
        public bool enableMouseControl = false;

        [Tooltip("When enabled, a label will be spawned on every chemical substance to display its formula and mass.")]
        public bool enableLabel = true;

        [Tooltip("Specifies the minimum level of logs to be printed in console.")]
        public LogLevel logLevel = LogLevel.None;

        public float MinMultiplierSquare { get; }

        public float MaxMultiplierSquare { get; }
         
        public ChemixConfig()
        {
            MinMultiplierSquare = minMultiplier * minMultiplier;
            MaxMultiplierSquare = maxMultiplier * maxMultiplier;
        }
    }
}